package com.yjck.ijpay.utils.wxutils;




import java.util.concurrent.ThreadLocalRandom;

/**
 * 默认请求消息处理类
 * 
 * @author phil
 * 
 */
public class MsgUtil {

	/**
	 * 支付参数
	 * 
	 * @param params
	 * @return
	 */
	public static String abstractPayToXml(AbstractPayParams params,String apiKey) {
		String sign = SignatureUtil.createSign(params, apiKey, null);
		params.setSign(sign);
		return XmlUtil.toSplitXml(params);
	}
	

	/**
	 * 提现参数
	 * 
	 * @param params
	 * @return
	 */
	public static String abstractRePayToXml(StoreToUserParams params,String apiKey) {
		String sign = SignatureUtil.createSign(params, apiKey, null);
		params.setSign(sign);
		return XmlUtil.toSplitXml(params);
	}
	
	public static String abstractPayToXml(AbstractPayParams params) {
		String sign = SignatureUtil.createSign(params, null, null);
		params.setSign(sign);
		return XmlUtil.toSplitXml(params);
	}

	/**
	 * 获得随机字符串
	 * 
	 * @return
	 */
	public static String createNonceStr() {
		return MD5.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "utf-8");
	}



}